package com.atguigu.gmall.item.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 自定义线程池
 */
@Configuration
public class ItemThreadPoolConfig {

    /**
     * 将线程池注入到容器中去
     * @return
     */
    @Bean
    public ThreadPoolExecutor getThreadPoolExecutor() {
        ThreadPoolExecutor threadPoolExecutor =
                new ThreadPoolExecutor(
                        12,
                        24,
                        60,
                        TimeUnit.SECONDS,
                        new ArrayBlockingQueue<>(10000));
        return threadPoolExecutor;
    }
}
